package com.wlw.admin.pluginapp;

import android.content.Context;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;

import java.lang.reflect.Method;

public class MainActivity extends BaseActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        Log.e("onCreate", "aaaaaaaaaaaa");
        super.onCreate(savedInstanceState);
        initView(savedInstanceState);
    }

    private void initView(Bundle savedInstanceState) {
//        Class<MainActivity> localClass = MainActivity.class;
//        Method[] methods = localClass.getDeclaredMethods();
//        for (Method method : methods) {
//            String name = method.getName();
//            Log.d("name", name);
//            if ("setProxy".equals(name) || TextUtils.equals("onCreate", name)) {
//                Log.e("name", name);
//            }
//        }
//
//        Method[] methods1 = localClass.getMethods();
//        for (Method method : methods1) {
//            String name = method.getName();
//            if ("setProxy".equals(name) || TextUtils.equals("onCreate", name)) {
//                Log.e("name1", name);
//            }
//        }
        mProxyActivity.setContentView(generateContentView(mProxyActivity));
    }

    private View generateContentView(Context context) {
        LinearLayout layout = new LinearLayout(context);
        layout.setOrientation(LinearLayout.VERTICAL);
        layout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
        Button button = new Button(context);
        button.setText("next");
        button.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
        layout.addView(button);

        button.setOnClickListener(v ->
                startActivityByProxy(SecondActivity.class.getCanonicalName()));
        Log.e("onCreate", "bbbbbbbb");
        return layout;
    }
}
